<template>
  <div class="input-line">
    <div class="editable" contenteditable data-placeholder='输入"/"快速插入内容' ref="editDiv"/>
  </div>
</template>
<script setup>
import { nextTick, onMounted, ref} from 'vue'
const props = defineProps(['enter', 'init'])
onMounted(()=>{
  if(props.enter){
    nextTick(()=>{
      editDiv.value.focus()
    })
  }
  if(props.init){
    editDiv.value.innerText = props.init
  }
})
const editDiv = ref(null)
</script>

<style lang="scss" scoped>
.input-line {
  &:first-child {
    margin-top: 10px;
  }
  .editable {
    cursor: text;
    text-align: justify;
    line-height: 1.7;
    outline: none;
    &:empty:after {
      content: attr(data-placeholder);
      color: #cacaca;
    }
  }
}
</style>
